package com.cn.learn.jpa.domain.model;

import lombok.Data;

/**
 * @ClassName ResultModel
 * @Description 结果集对象
 * @Author JiJiang
 * @Date 2022/9/14 15:19
 * @Version 1.0
 */

@Data
public class ResultModel {

    private Integer code;
    private String msg;
    private Integer count;
    private Object data;

    private ResultModel() {

    }


    //region 获取结果集对象

    /**
     * @MethodName getResultModel
     * @Description 传入全部参数
     * @Param [code, msg, data]
     * @Return com.xn.wanxi.bootlearnstep7.domain.model.ResultModel
     **/
    public static ResultModel getResultModel(int code, String msg, int count, Object data) {

        ResultModel resultModel = new ResultModel();
        resultModel.setCode(code);
        resultModel.setMsg(msg);
        resultModel.setCount(count);
        resultModel.setData(data);
        return resultModel;
    }

    /**
     * @MethodName getResultModel
     * @Description 传入消息、数据信息
     * @Param [msg, data]
     * @Return com.xn.wanxi.bootlearnstep7.domain.model.ResultModel
     **/
    public static ResultModel getResultModel(String msg, Object data) {
        return getResultModel(0, msg, 0, data);
    }

    public static ResultModel getResultModel(String msg) {
        return ResultModel.getResultModel(msg, null);
    }

    public static ResultModel getResultModel(Object data) {
        return ResultModel.getResultModel(null, data);
    }


    public static ResultModel getResultModel(int count, String msg) {
      return   getResultModel(0, msg, count, null);

    } public static ResultModel getResultModel(int count, Object data) {
      return   getResultModel(0, null, count, data);

    }
    //endregion


}
